package com.sskj.mine.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.support.design.widget.BottomSheetDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.jakewharton.rxbinding2.widget.RxTextView;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.FabiBuySellEnum;
import com.sskj.lib.bean.TabItem;
import com.sskj.lib.util.CoinUtil;
import com.sskj.mine.R;

import java.math.BigDecimal;
import java.util.ArrayList;

public class MineTipUtil {
    public static MaterialDialog mineLogout(Context context, String titleText, String contentText, OnInputList onInputList) {
        MaterialDialog dialog = new MaterialDialog.Builder(context)
                .customView(R.layout.mine_logout, false)
                .autoDismiss(false)
                .cancelable(false)
                .show();
        View view = dialog.getCustomView();
        ((ViewGroup) (view.getParent())).setBackgroundColor(Color.TRANSPARENT);
        ((ViewGroup) (view.getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
        ((ViewGroup) (view.getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
        ((ViewGroup) (view.getParent().getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
        ((ViewGroup) (view.getParent().getParent().getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);

        TextView submitTv = view.findViewById(R.id.mine_confirm);
        TextView cancelTv = view.findViewById(R.id.mine_cancel);
        TextView title = view.findViewById(R.id.mine_title);
        TextView content = view.findViewById(R.id.mine_content);
        if (!TextUtils.isEmpty(titleText)) {
            title.setText(titleText);
        }
        if (!TextUtils.isEmpty(contentText)) {
            content.setText(contentText);
        }
        ClickUtil.click(cancelTv, () -> {
            dialog.dismiss();
        });
        ClickUtil.click(submitTv, () -> {
            onInputList.onSure();
            dialog.dismiss();
        });
        return dialog;
    }


    public static BottomSheetDialog showWallet(Activity activity, OnOutList onOutList) {
        BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(activity);
        View rootView = LayoutInflater.from(activity).inflate(R.layout.mine_bottom_layout, null, false);
        TextView tvBtc = rootView.findViewById(R.id.btc);
        TextView tvEth = rootView.findViewById(R.id.eth);
        ClickUtil.click(tvBtc, () -> {
            onOutList.onSure(0);
            bottomSheetDialog.dismiss();
        });
        ClickUtil.click(tvEth, () -> {
            onOutList.onSure(1);
            bottomSheetDialog.dismiss();
        });
        bottomSheetDialog.setContentView(rootView);
        bottomSheetDialog.setCancelable(true);
        bottomSheetDialog.setCanceledOnTouchOutside(true);
        return bottomSheetDialog;

    }

    public interface OnInputList {
        void onSure();
    }

    public interface OnOutList {
        void onSure(int position);
    }
}
